Skip to content
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

[pdf] Wrong glyph displayed on iOS and Adobe Reader (fine for other font) #61

Closed
oliverpool opened this issue Aug 15, 2020 · 2 comments
Closed

Comments

@oliverpool
Copy link
Contributor

I generated the following pdf by running this program:
bug.pdf

package main

import (
	"image/color"
	"os"

	"github.com/tdewolff/canvas"
	"github.com/tdewolff/canvas/pdf"
)

func fontOTF() *canvas.FontFamily {
	fontFamily := canvas.NewFontFamily("SourceSerifPro")
	fontFamily.Use(canvas.CommonLigatures)
	err := fontFamily.LoadFontFile("SourceSerifPro-Regular.otf", canvas.FontRegular)
	if err != nil {
		panic(err)
	}
	return fontFamily
}

func fontDejaVuTTF() *canvas.FontFamily {
	fontFamily := canvas.NewFontFamily("times")
	fontFamily.Use(canvas.CommonLigatures)
	if err := fontFamily.LoadLocalFont("NimbusRoman-Regular", canvas.FontRegular); err != nil {
		panic(err)
	}
	return fontFamily
}

func main() {
	f, err := os.Create("bug.pdf")
	if err != nil {
		panic(nil)
	}
	defer f.Close()
	pdf := pdf.New(f, 100, 100)

	////////////////
	face := fontOTF().Face(16, color.Black, canvas.FontRegular, canvas.FontNormal)
	txt := canvas.NewTextLine(face, "SourceSerifPro-Regular.otf\nL (big l) is like I (big i) on iOS (/ is like [)", canvas.Left)
	pdf.RenderText(txt, canvas.Identity.Translate(0, 50))
	////////////////
	face = fontDejaVuTTF().Face(16, color.Black, canvas.FontRegular, canvas.FontNormal)
	txt = canvas.NewTextLine(face, "NimbusRoman-Regular\nL (big l) is like I (big i) on iOS (/ is like [)", canvas.Left)
	pdf.RenderText(txt, canvas.Identity.Translate(0, 20))

	err = pdf.Close()
	if err != nil {
		panic(nil)
	}
}

(you can get the OTF font at https://github.com/adobe-fonts/source-serif-pro)

It produces the following pdf:
bug.pdf

It displays fine on all PDF reader that I could test on linux (evince, firefox, chromium), but on the first line is wrong on Adobe Reader and iOS: the L is displayed like a I (the other letters look ok)
image

Do you have any idea what might be wrong ? (or at least in which direction should I search?)

@tdewolff
Copy link
Owner

Pretty sure this has to do with #60 where we use the wrong encoding. It might also be related to the fact that copying text from the PDF gives garbage...

@tdewolff
Copy link
Owner

tdewolff commented Feb 15, 2021

This should be fixed in the develop branch, see the roadmap for more information: #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants