-
Notifications
You must be signed in to change notification settings - Fork 18k
x/image/font/sfnt: horizontal metrics table (hmtx) validation is incorrect #28379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Change https://golang.org/cl/144080 mentions this issue: |
Values in the font: |
Change https://golang.org/cl/146081 mentions this issue: |
In case anyone else was confused, the square brackets in @dennwc's original post: The original bug report also claimed that the spec allows for just Still, a comment in the freetype library's ttload.c says:
and also, eyeballing its tt_face_get_metrics function in ttmtx.c suggests that FreeType doesn't enforce that the hmtx table is exactly |
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
The library assumes the hmtx size to be equal to 2*nGlyph + 2*nHm, which is a simplification of 4*nHm + 2*(nGlyph-nHm) as described in the spec. However, fonts seen in the wild sometimes omit the second term (left side bearings), making validation to fail. CL fixes the validation code by allowing to omit the second term. Fixes golang/go#28379 Change-Id: I2293e498e72f95e5fe08c2b375ea7b020d06cde3 Reviewed-on: https://go-review.googlesource.com/c/144080 Reviewed-by: Nigel Tao <nigeltao@golang.org>
What did you do?
Parse an embedded TTF font from PDF object.
What did you expect to see?
no error
What did you see instead?
Details
It seems that the validation code for
hmtx
table is incorrect. The library assumes2*numGlyphs + 2*numHMetrics
, while the spec describes it as4*numHMetrics [+ 2*(numGlyphs-numHMetrics)]
.The text was updated successfully, but these errors were encountered: