Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: experimental/webtry/webtry.go

Issue 635373002: In the generated fiddle, set the portable fonts flag first. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/webtry/build ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "crypto/md5" 5 "crypto/md5"
6 "database/sql" 6 "database/sql"
7 "encoding/base64" 7 "encoding/base64"
8 "encoding/binary" 8 "encoding/binary"
9 "encoding/json" 9 "encoding/json"
10 "flag" 10 "flag"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return writeTemplate(filename, t, userCode{Code: code, Titlebar: Titleba r{GitHash: gitHash, GitInfo: gitInfo}}) 365 return writeTemplate(filename, t, userCode{Code: code, Titlebar: Titleba r{GitHash: gitHash, GitInfo: gitInfo}})
366 } 366 }
367 367
368 // expandCode expands the template into a file and calculates the MD5 hash. 368 // expandCode expands the template into a file and calculates the MD5 hash.
369 func expandCode(code string, source int) (string, error) { 369 func expandCode(code string, source int) (string, error) {
370 // in order to support fonts in the chroot jail, we need to make sure 370 // in order to support fonts in the chroot jail, we need to make sure
371 // we're using portable typefaces. 371 // we're using portable typefaces.
372 // TODO(humper): Make this more robust, supporting things like setTypef ace 372 // TODO(humper): Make this more robust, supporting things like setTypef ace
373 373
374 inputCodeLines := strings.Split(code, "\n") 374 inputCodeLines := strings.Split(code, "\n")
375 » outputCodeLines := []string{} 375 » outputCodeLines := []string{"DECLARE_bool(portableFonts);"}
376 for _, line := range inputCodeLines { 376 for _, line := range inputCodeLines {
377 outputCodeLines = append(outputCodeLines, line) 377 outputCodeLines = append(outputCodeLines, line)
378 » » if strings.HasPrefix(strings.TrimSpace(line), "SkPaint ") { 378 » » if strings.HasPrefix(strings.TrimSpace(line), "SkPaint p") {
379 » » » outputCodeLines = append(outputCodeLines, "sk_tool_utils ::set_portable_typeface(&p);") 379 » » » outputCodeLines = append(outputCodeLines, "FLAGS_portabl eFonts = true;")
380 » » » outputCodeLines = append(outputCodeLines, "sk_tool_utils ::set_portable_typeface(&p, \"Helvetica\", SkTypeface::kNormal);")
380 } 381 }
381 } 382 }
382 383
383 fontFriendlyCode := strings.Join(outputCodeLines, "\n") 384 fontFriendlyCode := strings.Join(outputCodeLines, "\n")
384 385
385 h := md5.New() 386 h := md5.New()
386 h.Write([]byte(fontFriendlyCode)) 387 h.Write([]byte(fontFriendlyCode))
387 binary.Write(h, binary.LittleEndian, int64(source)) 388 binary.Write(h, binary.LittleEndian, int64(source))
388 hash := fmt.Sprintf("%x", h.Sum(nil)) 389 hash := fmt.Sprintf("%x", h.Sum(nil))
389 // At this point we are running in skia/experimental/webtry, making cach e a 390 // At this point we are running in skia/experimental/webtry, making cach e a
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler)) 873 http.HandleFunc("/sources/", autogzip.HandleFunc(sourcesHandler))
873 874
874 // Resources are served directly 875 // Resources are served directly
875 // TODO add support for caching/etags/gzip 876 // TODO add support for caching/etags/gzip
876 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./")))) 877 http.Handle("/res/", autogzip.Handle(http.FileServer(http.Dir("./"))))
877 878
878 // TODO Break out /c/ as it's own handler. 879 // TODO Break out /c/ as it's own handler.
879 http.HandleFunc("/", autogzip.HandleFunc(mainHandler)) 880 http.HandleFunc("/", autogzip.HandleFunc(mainHandler))
880 log.Fatal(http.ListenAndServe(*port, nil)) 881 log.Fatal(http.ListenAndServe(*port, nil))
881 } 882 }
OLDNEW
« no previous file with comments | « experimental/webtry/build ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698