-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
91 changed files
with
34,874 additions
and
4 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
QuickLook.Plugin/QuickLook.Plugin.FontViewer/OurOpenFontSystemSetup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//MIT, 2016-present, WinterDev | ||
using System; | ||
using System.IO; | ||
|
||
using Typography.OpenFont.WebFont; | ||
using BrotliSharpLib; | ||
using System.IO.Compression; | ||
|
||
namespace SampleWinForms; | ||
|
||
public static class OurOpenFontSystemSetup | ||
{ | ||
public static void SetupWoffDecompressFunctions() | ||
{ | ||
// | ||
//Woff | ||
// WoffDefaultZlibDecompressFunc.DecompressHandler = (byte[] compressedBytes, byte[] decompressedResult) => | ||
// { | ||
// //ZLIB | ||
// //**** | ||
// //YOU can change to your prefer decode libs*** | ||
// //**** | ||
|
||
// bool result = false; | ||
// try | ||
// { | ||
// var inflater = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(); | ||
// inflater.SetInput(compressedBytes); | ||
// inflater.Inflate(decompressedResult); | ||
//#if DEBUG | ||
// long outputLen = inflater.TotalOut; | ||
// if (outputLen != decompressedResult.Length) | ||
// { | ||
// } | ||
//#endif | ||
|
||
// result = true; | ||
// } | ||
// catch (Exception ex) | ||
// { | ||
// } | ||
// return result; | ||
// }; | ||
//Woff2 | ||
|
||
Woff2DefaultBrotliDecompressFunc.DecompressHandler = (byte[] compressedBytes, Stream output) => | ||
{ | ||
//BROTLI | ||
//**** | ||
//YOU can change to your prefer decode libs*** | ||
//**** | ||
|
||
bool result = false; | ||
try | ||
{ | ||
using (var ms = new MemoryStream(compressedBytes)) | ||
{ | ||
ms.Position = 0;//set to start pos | ||
Decompress(ms, output); | ||
} | ||
result = true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
} | ||
return result; | ||
}; | ||
} | ||
|
||
static void Decompress(Stream input, Stream output) | ||
{ | ||
try | ||
{ | ||
using (var bs = new BrotliStream(input, CompressionMode.Decompress)) | ||
using (var ms = new MemoryStream()) | ||
{ | ||
bs.CopyTo(output); | ||
} | ||
} | ||
catch (IOException ex) | ||
{ | ||
throw ex; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.