Skip to content

Commit

Permalink
Use monospace font for state labels
Browse files Browse the repository at this point in the history
When the timeline chart is zoom in/out, the label of each state
will be modified to fit the width of the state. When the width
of the state is smaller than the width of the label, the text is
truncated. To determine how much text is truncated, the timeline
chart uses the ratio of width of label text / width of state.
However, since the width of each charater is different, this ratio
does not well-represent how much text can be displayed in the label,
causing text to overflow out of the state. The solution is to use a
monospace font, in which all characters are of the same width.

This commit changes the font-family of the labels from Verdana to
monospace. With this change, the browser will default to the monospace
font of the OS and make the texts fit within the states.

Fixes #224.

Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
  • Loading branch information
hoangphamEclipse committed Dec 23, 2022
1 parent 266fb6b commit 4c1edfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timeline-chart/src/time-graph-font-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class FontController {
private fontColorMap: Map<number, string>;
private defaultFontName: string = "LabelFont8White";

constructor(fontFamily: string = "Verdana") {
constructor(fontFamily: string = "monospace") {
this.fontFamily = fontFamily;
this.fontNameMap = new Map<number, Map<string, string>>();
this.fontColorMap = new Map<number, string>();
Expand All @@ -25,7 +25,7 @@ export class FontController {
fontFamily: this.fontFamily,
fontSize: fontSize,
fill: fontColor === "White" ? "white" : "black",
fontWeight: 900
fontWeight: "bold"
};
PIXI.BitmapFont.from(fontName, fontStyle, { chars: PIXI.BitmapFont.ASCII });
return fontName;
Expand Down

0 comments on commit 4c1edfd

Please sign in to comment.