Skip to content

Commit

Permalink
Fix system font kerning (#21)
Browse files Browse the repository at this point in the history
* Changed position variables from ints to floats

* Get float values from GlyphMetrics
  • Loading branch information
arlith authored and blackears committed Aug 7, 2018
1 parent d6b6fe9 commit faba377
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public class MissingGlyph extends ShapeElement
//We may define a path
private Shape path = null;
//Alternately, we may have child graphical elements
private int horizAdvX = -1; //Inherits font's value if not set
private int vertOriginX = -1; //Inherits font's value if not set
private int vertOriginY = -1; //Inherits font's value if not set
private int vertAdvY = -1; //Inherits font's value if not set
private float horizAdvX = -1; //Inherits font's value if not set
private float vertOriginX = -1; //Inherits font's value if not set
private float vertOriginY = -1; //Inherits font's value if not set
private float vertAdvY = -1; //Inherits font's value if not set

/**
* Creates a new instance of Font
Expand Down Expand Up @@ -131,22 +131,22 @@ protected void build() throws SVGException
//Read glyph spacing info
if (getPres(sty.setName("horiz-adv-x")))
{
horizAdvX = sty.getIntValue();
horizAdvX = sty.getFloatValue();
}

if (getPres(sty.setName("vert-origin-x")))
{
vertOriginX = sty.getIntValue();
vertOriginX = sty.getFloatValue();
}

if (getPres(sty.setName("vert-origin-y")))
{
vertOriginY = sty.getIntValue();
vertOriginY = sty.getFloatValue();
}

if (getPres(sty.setName("vert-adv-y")))
{
vertAdvY = sty.getIntValue();
vertAdvY = sty.getFloatValue();
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ public void render(Graphics2D g) throws SVGException
//Do not push or pop stack
}

public int getHorizAdvX()
public float getHorizAdvX()
{
if (horizAdvX == -1)
{
Expand All @@ -187,7 +187,7 @@ public int getHorizAdvX()
return horizAdvX;
}

public int getVertOriginX()
public float getVertOriginX()
{
if (vertOriginX == -1)
{
Expand All @@ -196,7 +196,7 @@ public int getVertOriginX()
return vertOriginX;
}

public int getVertOriginY()
public float getVertOriginY()
{
if (vertOriginY == -1)
{
Expand All @@ -205,7 +205,7 @@ public int getVertOriginY()
return vertOriginY;
}

public int getVertAdvY()
public float getVertAdvY()
{
if (vertAdvY == -1)
{
Expand Down Expand Up @@ -260,31 +260,31 @@ public void setPath(Shape path)
/**
* @param horizAdvX the horizAdvX to set
*/
public void setHorizAdvX(int horizAdvX)
public void setHorizAdvX(float horizAdvX)
{
this.horizAdvX = horizAdvX;
}

/**
* @param vertOriginX the vertOriginX to set
*/
public void setVertOriginX(int vertOriginX)
public void setVertOriginX(float vertOriginX)
{
this.vertOriginX = vertOriginX;
}

/**
* @param vertOriginY the vertOriginY to set
*/
public void setVertOriginY(int vertOriginY)
public void setVertOriginY(float vertOriginY)
{
this.vertOriginY = vertOriginY;
}

/**
* @param vertAdvY the vertAdvY to set
*/
public void setVertAdvY(int vertAdvY)
public void setVertAdvY(float vertAdvY)
{
this.vertAdvY = vertAdvY;
}
Expand Down
4 changes: 2 additions & 2 deletions svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public MissingGlyph getGlyph(String unicode)
glyph.setPath(vec.getGlyphOutline(0));

GlyphMetrics gm = vec.getGlyphMetrics(0);
glyph.setHorizAdvX((int)gm.getAdvanceX());
glyph.setVertAdvY((int)gm.getAdvanceY());
glyph.setHorizAdvX(gm.getAdvanceX());
glyph.setVertAdvY(gm.getAdvanceY());
glyph.setVertOriginX(0);
glyph.setVertOriginY(0);

Expand Down

0 comments on commit faba377

Please sign in to comment.