Skip to content

feat(core): support custom mime type for canvas loadImage#53

Draft
DGCK81LNN wants to merge 1 commit into
koishijs:mainfrom
DGCK81LNN:main
Draft

feat(core): support custom mime type for canvas loadImage#53
DGCK81LNN wants to merge 1 commit into
koishijs:mainfrom
DGCK81LNN:main

Conversation

@DGCK81LNN

Copy link
Copy Markdown

Fix #51

@DGCK81LNN

DGCK81LNN commented Sep 10, 2024

Copy link
Copy Markdown
Author

Actually this does not work for my use case because the loaded SVG image taints the canvas, making it throw an error when exporting. I had to use a data: URL in index.html instead of a Blob.

My SVG (generated code):

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 160"><style>@font-face{font-family:"Iosevka Custom";font-stretch:semi-condensed;font-weight:bold;src:url("data:font/woff2;base64,[...]")}@font-face{font-family:"Sarasa Mono SC";src:url("data:font/woff2;base64,[...]")}@font-face{font-family:"Italian plates 1999";src:url("data:font/woff2;base64,[...]")}@font-face{font-family:"Code2000";src:url("data:font/woff2;base64,[...]")}@font-face{font-family:"方正姚体";src:url("data:font/woff2;base64,[...]")}.try{width:104px;height:100%;font-family:'Sarasa Mono SC';font-stretch:normal;font-weight:400;font-size:88px;line-height:160px}.plate:not(.plate-old) .try{position:absolute;left:0;top:0}.plate-small .try{width:65px;font-size:55px;line-height:100px}.try-wrap{display:inline}.try-wrap::after{content:" ";white-space:pre}.plate{position:relative;width:396.8px;height:160px;font-family:'Iosevka Custom';font-stretch:semi-condensed;font-weight:700;line-height:160px;font-size:112px;letter-spacing:-3.2px;padding-right:3.2px;text-align:center;font-optical-sizing:none}.plate-small{width:248px;height:100px;border-radius:5px;line-height:100px;font-size:70px;letter-spacing:-2px;padding-right:2px}.chair{position:absolute;left:0;top:0;z-index:100;width:100%;height:40px;font-family:'Code2000';font-stretch:normal;font-weight:normal;font-size:32px;line-height:40px;color:blue;letter-spacing:normal}.elec{position:absolute;left:0;top:0;z-index:100;width:100%;height:40px;font-family:'Sarasa Mono SC';font-weight:normal;font-size:24px;line-height:40px;letter-spacing:normal}.plate-small .elec{width:250px;height:25px;font-size:15px;line-height:25px}.plate-old{width:320px;height:160px;font-family:'Italian plates 1999';display:flex;font-weight:normal;padding:0;letter-spacing:normal}.plate-old.plate-small{width:200px;height:100px;padding:0}.plate-old .edge{width:8px}.plate-old.plate-small .edge{width:5px}.plate-old .middle{width:48px}.plate-old.plate-small .middle{width:30px}.plate-old .dot{width:16px}.plate-old.plate-small .dot{width:10px}.plate-old .try{width:96px;font-size:88px}.plate-old.plate-small .try{width:45px;font-family:"方正姚体";font-size:50px}.plate-old .middle5{width:56px}.plate-old .dot5{width:24px}.plate-old .edgelong{width:16px}.plate-old .middle4{width:64px}.plate-old .dot4{width:32px}.plate-old.plate-small .edgelong{width:10px}.plate-old.plate-small .middle4{width:40px}.plate-old.plate-small .dot4{width:20px}</style><path d="M8,0A8,8,0,0,0,0,8V152A8,8,0,0,0,8,160H312A8,8,0,0,0,320,152V8A8,8,0,0,0,312,0ZM55,25A5,5,0,0,1,55,15H75A5,5,0,0,1,75,25ZM245,25A5,5,0,0,1,245,15H265A5,5,0,0,1,265,25Z" fill="white"/><foreignObject x="0" y="0" width="320" height="160"><div xmlns="http://www.w3.org/1999/xhtml" class="plate plate-old" style="color: black"><div class="elec">电&#160;&#160;&#160;动</div><div class="chair">♿</div><div class="edge"> </div><div class="middle">A</div><div class="middle">B</div><div class="dot">·</div><div class="middle">1</div><div class="middle">2</div><div class="middle">3</div><div class="middle">4</div><div class="edge"> </div></div></foreignObject></svg>

@DGCK81LNN DGCK81LNN marked this pull request as draft September 10, 2024 11:01
@DGCK81LNN DGCK81LNN marked this pull request as draft September 10, 2024 11:01
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

Successfully merging this pull request may close these issues.

Feature request: make CanvasService.loadImage() take an additional type parameter

1 participant