-module(hmtx). -export([parse_hmtx_table/1]). -include("sizes.hrl"). -define(LONG_HOR_METRIC_SIZE, (?U16+?I16)). parse_long_hor_metric(<>) -> [[ {advance_width, AdvanceWidth}, {lsb, Lsb} ] | parse_long_hor_metric(Rest)]; parse_long_hor_metric(<<>>) -> []. parse_left_side_bearing(<>) -> [LeftSideBearing | parse_left_side_bearing(Rest)]; parse_left_side_bearing(<<>>) -> []. parse_hmtx_table( <>>> HMetrics:(NumberOfHMetrics*?LONG_HOR_METRIC_SIZE)/binary, LeftSideBearing:((NumGlyphs-NumberOfHMetrics)*?I16)/binary >>) -> [ {h_metrics, parse_long_hor_metric(HMetrics)}, {left_side_bearing, parse_left_side_bearing(LeftSideBearing)} ].