Skip to content

Commit

Permalink
Implement convertUnit functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
habbisify authored Mar 18, 2021
1 parent 3d8f1a3 commit 358db60
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1674,4 +1674,40 @@ private List<Integer> applyGSUBRules(GsubWorker gsubWorker, ByteArrayOutputStrea
return glyphIdsAfterGsub;

}

/**
* Set the text rise value, i.e. move the baseline up or down. This is useful for drawing
* superscripts or subscripts.
*
* @param items
* @param unit_type
* @throws IllegalArgumentException
*/
public List<Float> convertUnit(List<Float> items, String unit_type)
{
float multiplier = 1;
if (unit_type == "mm")
{
multiplier = 1 / (10 * 2.54f) * 72;
}
else if (unit_type == "inch")
{
multiplier = 72;
}
else
{
throw new IllegalArgumentException(
"could not find the unit type: " + unit_type);
}
List<Float> items_new = new ArrayList();
Iterator<Float> it = items.iterator();
while(it.hasNext())
{
Float item = it.next();
item *= multiplier;
items_new.add(item);
}

return items_new;
}
}

0 comments on commit 358db60

Please sign in to comment.