From 844b54130db3f8e1aa45539e4ca34b059c31d192 Mon Sep 17 00:00:00 2001
From: Florian Moser <git@famoser.ch>
Date: Thu, 29 Apr 2021 17:02:12 +0200
Subject: [PATCH] Add encoding explanation

---
 pdf/pdf.html | 70 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 10 deletions(-)

diff --git a/pdf/pdf.html b/pdf/pdf.html
index cb331dc..068a68e 100644
--- a/pdf/pdf.html
+++ b/pdf/pdf.html
@@ -13,7 +13,7 @@ class: center, middle
 
 # PDF = PestesDateiFormat
 
-<i>Imagine being able to send full text and graphics documents (newspapers, magazine articles, technical manuals, etc.) over electronic mail distribution networks. These documents could be viewed on any machine and any selected document could be printed locally. This capability would truly change the way information is managed.</i>
+<i>Imagine being able to send full text and graphics documents (...) [that] could be viewed on any machine (...). This capability would truly change the way information is managed.</i>
 
 <img src="images/thealternative-logo.jpg" width="30%">
 
@@ -303,25 +303,75 @@ class: center, middle
 
 ---
 
-# Supporting unicode
+# Text with default encoding / fonts
 
-`WinAnsiEncoding` is a single byte encoding; so are the other default encodings.  
+Can use embedd default fonts (`Helvetica`) with default encoding `WinAnsiEncoding`.
 
-What if I need a character not contained in these standard encodings (like chinese characters)?
+```html
+4 0 obj
+<</Font <</F 5 0 R>> /ProcSet [/PDF /Text]>>
+endobj
+5 0 obj
+<</Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding>>
+endobj
+```
 
-Steps:
-- Embed font which supports character as stream
-- Declare encoding of text (PDF) onto glyphs (font)
-- Declare meta data (widths of characters, ...)
+Then print text like:
+```html
+6 0 obj
+<</Length 59>>
+stream
+BT 1 0 0 1 22 20 cm 1 w /F 12 Tf 14.4 TL (Hello world)Tj ET
+endstream
+```
+
+---
+
+# How about unicode?
 
-=> Requires deep knowledge about font
+Default encodings are all single byte encoding.
+What if I need a multi-byte / non-european character?
+
+Embedd .ttf file:
+
+```html
+8 0 obj
+<</Type /FontDescriptor /FontName /OpenSansRegular /Flags 6 
+/FontBBox [96 0 561 953] /ItalicAngle 0 /Ascent 1094 /Descent -300 
+/CapHeight 0 /StemV 0 /FontFile3 9 0 R>>
+endobj
+9 0 obj
+<</Length 4274 /Subtype /OpenType>>
+stream
+(...)
+endstream
+endobj
+```
+
+Still have to define encoding...
 
 ---
 
-# The PDF wayâ„¢: Roll your own
+# Roll your own encoding
 
+Define text encoding:
+```ps
+7 begincodespacerange
+<6c> <6c>
+<61> <68>
+endcodespacerange
+```
 
+Define how text maps to glyph indexes:
+```ps
+7 begincidrange
+<6c> <6c> 2
+<61> <67> 4
+<68> <68> 11
+endcidrange
+```
 
+Both these steps require deep knowledge about fonts!
 
 
 ---
-- 
GitLab