mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 07:26:09 +00:00 
			
		
		
		
	Embed font ok sur uwp mais pas sur android
This commit is contained in:
		
							parent
							
								
									dd4c0ca6f9
								
							
						
					
					
						commit
						3faa1d28f4
					
				
					 28 changed files with 72 additions and 9 deletions
				
			
		|  | @ -89,6 +89,9 @@ | |||
|     <PackageReference Include="System.Memory"> | ||||
|       <Version>4.5.2</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages"> | ||||
|       <Version>4.5.1</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="Xamarin.Essentials"> | ||||
|       <Version>1.1.0</Version> | ||||
|     </PackageReference> | ||||
|  |  | |||
|  | @ -191,7 +191,7 @@ | |||
|       <Private>True</Private> | ||||
|     </Reference> | ||||
|     <Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||||
|       <HintPath>..\..\packages\System.Text.Encoding.CodePages.4.5.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath> | ||||
|       <HintPath>..\..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||||
|       <HintPath>..\..\packages\System.Threading.Tasks.Extensions.4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath> | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ | |||
|   <package id="System.Numerics.Vectors" version="4.6.0-preview3.19128.7" targetFramework="net471" /> | ||||
|   <package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0-preview3.19128.7" targetFramework="net471" /> | ||||
|   <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net471" /> | ||||
|   <package id="System.Text.Encoding.CodePages" version="4.5.0" targetFramework="net471" /> | ||||
|   <package id="System.Text.Encoding.CodePages" version="4.5.1" targetFramework="net471" /> | ||||
|   <package id="System.Threading.Tasks.Extensions" version="4.6.0-preview.18571.3" targetFramework="net471" /> | ||||
|   <package id="Xamarin.Essentials" version="1.1.0" targetFramework="net471" /> | ||||
|   <package id="Xamarin.Forms" version="4.0.0.346134-pre9" targetFramework="net471" /> | ||||
|  |  | |||
|  | @ -221,6 +221,9 @@ | |||
|     <PackageReference Include="sqlite-net-pcl"> | ||||
|       <Version>1.6.258-beta</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages"> | ||||
|       <Version>4.5.1</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="Xamarin.Essentials"> | ||||
|       <Version>1.1.0</Version> | ||||
|     </PackageReference> | ||||
|  |  | |||
|  | @ -142,6 +142,9 @@ | |||
|     <PackageReference Include="sqlite-net-pcl"> | ||||
|       <Version>1.6.258-beta</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages"> | ||||
|       <Version>4.5.1</Version> | ||||
|     </PackageReference> | ||||
|     <PackageReference Include="Xamarin.Essentials"> | ||||
|       <Version>1.1.0</Version> | ||||
|     </PackageReference> | ||||
|  |  | |||
|  | @ -21,12 +21,48 @@ | |||
|   <ItemGroup> | ||||
|     <None Remove="OGL.txt" /> | ||||
|     <None Remove="Pdf\178_hd_01_feuille_de_perso_v1.pdf" /> | ||||
|     <None Remove="Pdf\AlverataIrregularPEMedium.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aBL.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aBS.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aDRS.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aRL.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aS.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aSI.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aSZI.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_aZL.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_DR.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_I.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_R.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_RB.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_RBI.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_RI.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_RZ.ttf" /> | ||||
|     <None Remove="Pdf\LinLibertine_RZI.ttf" /> | ||||
|     <None Remove="Pdf\MinionPro_It.ttf" /> | ||||
|     <None Remove="test.svg" /> | ||||
|   </ItemGroup> | ||||
| 
 | ||||
|   <ItemGroup> | ||||
|     <EmbeddedResource Include="OGL.txt" /> | ||||
|     <EmbeddedResource Include="Pdf\178_hd_01_feuille_de_perso_v1.pdf" /> | ||||
|     <EmbeddedResource Include="Pdf\AlverataIrregularPEMedium.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aBL.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aBS.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aDRS.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aRL.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aS.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aSI.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aSZI.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_aZL.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_DR.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_I.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_R.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_RB.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_RBI.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_RI.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_RZ.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\LinLibertine_RZI.ttf" /> | ||||
|     <EmbeddedResource Include="Pdf\MinionPro_It.ttf" /> | ||||
|     <EmbeddedResource Include="test.svg" /> | ||||
|   </ItemGroup> | ||||
| 
 | ||||
|  | @ -38,6 +74,7 @@ | |||
|     <PackageReference Include="SkiaSharp.Svg" Version="1.60.0" /> | ||||
|     <PackageReference Include="SkiaSharp.Views.Forms" Version="1.68.0" /> | ||||
|     <PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" /> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> | ||||
|     <PackageReference Include="Xamarin.Essentials" Version="1.1.0" /> | ||||
|     <PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" /> | ||||
|     <PackageReference Include="Xamarin.Forms.Visual.Material" Version="4.0.0.346134-pre9" /> | ||||
|  |  | |||
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/AlverataIrregularPEMedium.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/AlverataIrregularPEMedium.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_DR.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_DR.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_I.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_I.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_R.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_R.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RB.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RB.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RBI.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RBI.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RI.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RI.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RZ.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RZ.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RZI.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_RZI.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aBL.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aBL.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aBS.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aBS.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aDRS.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aDRS.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aRL.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aRL.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aS.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aS.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aSI.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aSI.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aSZI.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aSZI.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aZL.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/LinLibertine_aZL.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/MinionPro_It.ttf
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								AideDeJeu/AideDeJeu/Pdf/MinionPro_It.ttf
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -1034,9 +1034,9 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | |||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         public static HashSet<String> listFonts(PdfReader reader) | ||||
|         public static Dictionary<String, PRIndirectReference> listFonts(PdfReader reader) | ||||
|         { | ||||
|             HashSet<String> set = new HashSet<String>(); | ||||
|             Dictionary<String, PRIndirectReference> set = new Dictionary<String, PRIndirectReference>(); | ||||
|             //PdfReader reader = new PdfReader(src); | ||||
|             PdfDictionary resources; | ||||
|             for (int k = 1; k <= reader.NumberOfPages; ++k) | ||||
|  | @ -1047,7 +1047,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | |||
|             return set; | ||||
|             } | ||||
| 
 | ||||
|         public static void processResource(HashSet<String> set, PdfDictionary resource) | ||||
|         public static void processResource(Dictionary<String, PRIndirectReference> set, PdfDictionary resource) | ||||
|         { | ||||
|             if (resource == null) | ||||
|                 return; | ||||
|  | @ -1067,6 +1067,8 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | |||
|             { | ||||
|                 font = fonts.GetAsDict(key); | ||||
|                 String name = font.GetAsName(PdfName.BASEFONT).ToString(); | ||||
|                 var flat = resource.Keys; //.GetAsDict(PdfName.FILTER); | ||||
|                 var dic = font.GetAsStream(PdfName.BASEFONT); | ||||
|                 if (name.Length > 8 && name[7] == '+') | ||||
|                 { | ||||
|                     name = String.Format("{0} subset ({1})", name.Substring(8), name.Substring(1, 7)); | ||||
|  | @ -1084,7 +1086,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | |||
|                     else if (desc.Get(PdfName.FONTFILE3) != null) | ||||
|                         name += " (" + font.GetAsName(PdfName.SUBTYPE).ToString().Substring(1) + ") embedded"; | ||||
|                 } | ||||
|                 set.Add(name); | ||||
|                 set[name] = font.IndRef; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -1105,19 +1107,31 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | |||
|             //} | ||||
|             //pdfDoc.close(); | ||||
| 
 | ||||
| 
 | ||||
|             System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); | ||||
|             //PdfDocument pdfDoc = new PdfDocument(new PdfWriter()); | ||||
|             //var stream = DependencyService.Get<INativeAPI>().CreateStream("test.pdf"); | ||||
|             var stream = new FileStream(Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, "test.pdf"), FileMode.Create, FileAccess.ReadWrite); | ||||
| 
 | ||||
|             PdfReader reader = new PdfReader(AideDeJeu.Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.178_hd_01_feuille_de_perso_v1.pdf")); | ||||
| 
 | ||||
|             var set = listFonts(reader); | ||||
|             var fontPath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, "LinLibertine_aS.ttf"); | ||||
|             using (var inFont = AideDeJeu.Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.LinLibertine_aS.ttf")) | ||||
|             { | ||||
|                 using (var outFont = new FileStream(fontPath, FileMode.Create, FileAccess.ReadWrite)) | ||||
|                 { | ||||
|                     await inFont.CopyToAsync(outFont); | ||||
|                 } | ||||
|             } | ||||
|             //var set = listFonts(reader); | ||||
|             //var truc = findFontInPage(reader, "MinionPro-It", 1); | ||||
|             //var fonts = BaseFont.GetDocumentFonts(reader); | ||||
|             //var font = BaseFont.CreateFont("TMULFZ+MinionPro-It", BaseFont.WINANSI, BaseFont.EMBEDDED); | ||||
|             //var font = findFontInForm(reader, new PdfName("MinionPro-It")); | ||||
|             var font = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED); | ||||
|             FontFactory.Register(fontPath, "mafont"); | ||||
|             var mafont = FontFactory.GetFont("mafont", 20, iTextSharp.text.Font.BOLD); | ||||
|             //System.Text.Encoding.RegisterProvider(new System.Text.EncodingProvider()); | ||||
|             //var font = BaseFont.CreateFont("mafont", BaseFont.WINANSI, BaseFont.EMBEDDED); | ||||
|             var font = mafont.BaseFont; | ||||
|             //var font = BaseFont.CreateFont(PRIndirectReference.()); | ||||
|             //var font = findNamedFont(reader, ""); | ||||
| 
 | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ | |||
|   <ItemGroup> | ||||
|     <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.0.0-preview3.19153.1" /> | ||||
|     <PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" /> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> | ||||
|     <PackageReference Include="Xamarin.Essentials" Version="1.1.0" /> | ||||
|     <PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" /> | ||||
|     <PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" /> | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ | |||
|     <PackageReference Include="MSTest.TestAdapter" Version="2.0.0-beta2" /> | ||||
|     <PackageReference Include="MSTest.TestFramework" Version="2.0.0-beta2" /> | ||||
|     <PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" /> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> | ||||
|     <PackageReference Include="Xamarin.Essentials" Version="1.1.0" /> | ||||
|     <PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" /> | ||||
|     <PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" /> | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ | |||
|     <PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.6" /> | ||||
|     <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.0.0-preview3.19153.1" /> | ||||
|     <PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" /> | ||||
|     <PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> | ||||
|     <PackageReference Include="Xamarin.Essentials" Version="1.1.0" /> | ||||
|     <PackageReference Include="Xamarin.Forms" Version="4.0.0.346134-pre9" /> | ||||
|     <PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" /> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez