Skip to content

Commit

Permalink
rename localGuideline to guidelineGlyph + try to get font sources
Browse files Browse the repository at this point in the history
  • Loading branch information
ollimeier committed May 14, 2024
1 parent ea63be5 commit 13a1998
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/fontra/client/core/font-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export class FontController {
this._rootObject = {};
this._rootObject.glyphMap = getGlyphMapProxy(glyphMap, this.characterMap);
this._rootObject.axes = ensureDenseAxes(await this.font.getAxes());
// TODO: Guidelines Font, to the guidelines we need the font sources
// this._rootObject.sources = await this.font.getSources();
this._rootObject.unitsPerEm = await this.font.getUnitsPerEm();
this._rootObject.customData = await this.font.getCustomData();
this._rootClassDef = (await getClassSchema())["Font"];
Expand Down
24 changes: 15 additions & 9 deletions src/fontra/views/editor/visualization-layer-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,22 @@ registerVisualizationLayerDefinition({
context.font = `${fontSize}px fontra-ui-regular, sans-serif`;
context.textAlign = "center";

// TODO: Global Guidelines

// Draw local guidelines
for (const localGuideline of positionedGlyph.glyph.guidelines) {
// TODO: Guidelines Font
// Draw font guidelines
// const sourceIndex = positionedGlyph.glyph.sourceIndex;
// if (sourceIndex != undefined) {
// const source = model.fontController.sources[sourceIndex];
// console.log('source: ', source)
// }

// Draw glyph guidelines
for (const guidelineGlyph of positionedGlyph.glyph.guidelines) {
context.save();
context.strokeStyle = parameters.strokeColor;
context.lineWidth = parameters.strokeWidth;
// move to the origin of the guideline
context.translate(localGuideline.x, localGuideline.y);
context.rotate((localGuideline.angle * Math.PI) / 180);
context.translate(guidelineGlyph.x, guidelineGlyph.y);
context.rotate((guidelineGlyph.angle * Math.PI) / 180);
context.scale(1, -1);

// draw guideline origin marker
Expand All @@ -335,8 +341,8 @@ registerVisualizationLayerDefinition({
let textWidth;
let textHeight;
// draw name
if (localGuideline.name) {
const strLine = `${localGuideline.name}`;
if (guidelineGlyph.name) {
const strLine = `${guidelineGlyph.name}`;
textWidth = Math.max(context.measureText(strLine).width);
textHeight = Math.max(getTextHeight(context, strLine));

Expand All @@ -349,7 +355,7 @@ registerVisualizationLayerDefinition({
}

// draw the line
if (localGuideline.name) {
if (guidelineGlyph.name) {
// with name
strokeLineDashed(
context,
Expand Down

0 comments on commit 13a1998

Please sign in to comment.